package lsl.leetCode.year2023.test0303;

import java.util.*;

/**
 * description:
 *
 * @author: liushengli
 * data: 2023/3/3
 */
public class offer50 {
    public static void main(String[] args) {
        String a = "loveleetcode";
        System.out.println(firstUniqChar(a));
    }

    public static char firstUniqChar(String s) {
        char[] charArray = s.toCharArray();
        HashMap<Character, Integer> map = new HashMap<>();
        for (char i : charArray) {
            if (!map.containsKey(i)) {
                map.put(i, 1);
            } else {
                map.put(i, map.getOrDefault(i, 0) + 1);
            }

        }
        for (char i : charArray) {
            if (1 == map.get(i)) {
                return i;
            }
        }
        return ' ';
    }
}
